<template>
  <div class="forbidden-page">
    <div class="error-container">
      <div class="error-icon">
        <el-icon :size="120" color="#f56c6c">
          <Warning />
        </el-icon>
      </div>
      <h1 class="error-title">ForbiddenPage</h1>
      <h2 class="error-subtitle">权限不足</h2>
      <p class="error-message">抱歉，您没有访问此页面的权限。</p>
      <p class="error-message">请联系管理员获取相应权限。</p>
      
      <!-- 调试信息 -->
      <div class="debug-info" v-if="showDebug">
        <h3>调试信息：</h3>
        <p><strong>当前用户角色：</strong>{{ userInfo.role }}</p>
        <p><strong>用户权限：</strong>{{ userInfo.permissions }}</p>
        <p><strong>Store状态：</strong>{{ JSON.stringify(store.state.user, null, 2) }}</p>
      </div>
      
      <div class="action-buttons">
        <el-button type="primary" @click="goBack">返回上一页</el-button>
        <el-button @click="goHome">返回首页</el-button>
        <el-button @click="toggleDebug" type="info">显示调试信息</el-button>
      </div>
    </div>
  </div>
</template>

<script>
// 定义组件名称以符合ESLint规范
export default {
  name: 'ForbiddenPage'
}
</script>

<script setup>
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
import { Warning } from '@element-plus/icons-vue'

const router = useRouter()
const store = useStore()
const showDebug = ref(false)

const userInfo = computed(() => {
  const user = store.state.user.userInfo || store.state.user
  return {
    role: user.role || '未知',
    permissions: user.permissions || []
  }
})

const goBack = () => {
  router.go(-1)
}

const goHome = () => {
  router.push('/home')
}

const toggleDebug = () => {
  showDebug.value = !showDebug.value
}
</script>

<style scoped>
.forbidden-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.error-container {
  text-align: center;
  background: white;
  padding: 60px 40px;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  width: 90%;
}

.error-icon {
  margin-bottom: 30px;
}

.error-title {
  font-size: 72px;
  font-weight: bold;
  color: #f56c6c;
  margin: 0 0 20px 0;
  line-height: 1;
}

.error-subtitle {
  font-size: 28px;
  color: #303133;
  margin: 0 0 20px 0;
  font-weight: 600;
}

.error-message {
  font-size: 16px;
  color: #606266;
  line-height: 1.6;
  margin: 0 0 40px 0;
}

.debug-info {
  margin-bottom: 40px;
}

.debug-info h3 {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
  margin: 0 0 10px 0;
}

.debug-info p {
  font-size: 16px;
  color: #606266;
  line-height: 1.6;
}

.action-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.action-buttons .el-button {
  min-width: 120px;
}

@media (max-width: 768px) {
  .error-container {
    padding: 40px 20px;
  }
  
  .error-title {
    font-size: 56px;
  }
  
  .error-subtitle {
    font-size: 24px;
  }
  
  .action-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .action-buttons .el-button {
    width: 200px;
  }
}
</style> 